<?php
/**
 * Classe FORM da tabela PESSOA
 * 
 * @author			Mário R. Castro
 * @copyright		Voitech Sistema
 * @package			SEMAS
 * @subpackage		semas.application.controller
 * @version			1.0
*/
class App_Form_Pessoa extends Voitech_Form
{
	public function __construct($options=array())
	{
		parent::__construct($options);
		
		$this->setAttribs(array('name'=>'frmCadastroPessoa', 'id'=>'frmCadastroPessoa', 'class'=>'form last-child'));
		
		// add id element
        $this->addElement('hidden', 'co_pessoa');
        
        // remove id's decorators
        $this->getElement('co_pessoa')
            ->removeDecorator('DtDdWrapper')
            ->removeDecorator('HtmlTag')
            ->removeDecorator('Label');
		
		$noPessoa 	= new Zend_Form_Element_Text( 'no_pessoa' );
		$noPessoa->setLabel( 'Nome/Responsável:' )
				 ->setAttribs( array('size'=>'70','class'=> 'first-child last-child') )
		         ->addFilter( new Zend_Filter_StringTrim() )
				 ->addValidator( new Zend_Validate_StringLength( array( 'min'=>'3', 'max'=>'255' ) ) )
		         ->setDecorators( $this->_decoratorDefault )
				 ->setRequired( true );
		$this->addElement( $noPessoa );				
	
		
		$nuCpf 	= new Zend_Form_Element_Text( 'nu_cpf' );
		$nuCpf->setLabel( 'CPF:' )
				 ->setAttribs( array('size'=>'15','maxlength'=>'11','class'=> 'first-child last-child') )
		         ->addFilter( new Zend_Filter_StringTrim() )
				 ->addValidator( new Zend_Validate_StringLength( array( 'min'=>'11', 'max'=>'14' ) ) )
		         ->setDecorators( $this->_decoratorLeft );
		$this->addElement( $nuCpf );		
                
 		$nuRg 	= new Zend_Form_Element_Text( 'nu_rg' );
		$nuRg->setLabel( 'RG:' )
				 ->setAttribs( array('size'=>'10','class'=> 'first-child last-child') )
		         ->addFilter( new Zend_Filter_StringTrim() )
				 ->addValidator( new Zend_Validate_StringLength( array( 'min'=>'3', 'max'=>'15' ) ) )
		         ->setDecorators( $this->_decoratorLeft );
		$this->addElement( $nuRg );               

		$nuRgEmissor 	= new Zend_Form_Element_Text( 'no_rg_emissor' );
		$nuRgEmissor->setLabel( 'Emissor:' )
				 ->setAttribs( array('size'=>'10','class'=> 'first-child last-child') )
		         ->addFilter( new Zend_Filter_StringTrim() )
				 ->addValidator( new Zend_Validate_StringLength( array( 'min'=>'3', 'max'=>'15' ) ) )
		         ->setDecorators( $this->_decoratorLeft );
		$this->addElement( $nuRgEmissor );  

		$obParamUfRepositorio = new App_Model_ParamUfRepository();
        $selectBox = new Zend_Form_Element_Select( 'sg_uf_rg_emissor' );
            $selectBox->setLabel('UF Emissor:');
            $selectBox->setAttribs( array('class'=> 'last-child' ) );
            $selectBox->setDecorators( $this->_decoratorDefault );
            $selectBox->addMultiOptions( Voitech_Util::converteModeloArrayCombo($obParamUfRepositorio->listarTodos(array('st_ativo'=>'S'))
                                            , 'SgUf', 'SgUf', true) );
            $selectBox->addFilters( array('StringTrim','StripTags') );
        $this->addElement( $selectBox );

		$noEndereco 	= new Zend_Form_Element_Text( 'no_endereco' );
		$noEndereco->setLabel( 'Endereço:' )
				 ->setAttribs( array('size'=>'70','class'=> 'first-child last-child') )
		         ->addFilter( new Zend_Filter_StringTrim() )
				 ->addValidator( new Zend_Validate_StringLength( array( 'min'=>'3', 'max'=>'255' ) ) )
		         ->setDecorators( $this->_decoratorDefault );
		$this->addElement( $noEndereco );	

		$noComple 	= new Zend_Form_Element_Text( 'no_complemento' );
		$noComple->setLabel( 'Complemento:' )
				 ->setAttribs( array('size'=>'38','class'=> 'first-child last-child') )
		         ->addFilter( new Zend_Filter_StringTrim() )
				 ->addValidator( new Zend_Validate_StringLength( array( 'min'=>'3', 'max'=>'255' ) ) )
		         ->setDecorators( $this->_decoratorLeft );
		$this->addElement( $noComple );	

		$noBairro 	= new Zend_Form_Element_Text( 'no_bairro' );
		$noBairro->setLabel( 'Bairro:' )
				 ->setAttribs( array('size'=>'25','class'=> 'first-child last-child') )
		         ->addFilter( new Zend_Filter_StringTrim() )
				 ->addValidator( new Zend_Validate_StringLength( array( 'min'=>'3', 'max'=>'255' ) ) )
		         ->setDecorators( $this->_decoratorDefault );
		$this->addElement( $noBairro );	

		$obParamUfRepositorio = new App_Model_ParamUfRepository();
        $selectBox = new Zend_Form_Element_Select( 'sg_uf' );
            $selectBox->setLabel('UF:');
            $selectBox->setAttribs( array('class'=> 'last-child' ) );
            $selectBox->setDecorators( $this->_decoratorLeft );
            $selectBox->addMultiOptions( Voitech_Util::converteModeloArrayCombo($obParamUfRepositorio->listarTodos(array('st_ativo'=>'S'))
                                            , 'SgUf', 'SgUf', true) );
            $selectBox->addFilters( array('StringTrim','StripTags') );
        $this->addElement( $selectBox );

        $selectBox = new Zend_Form_Element_Select( 'co_cidade' );
            $selectBox->setLabel('Cidade:');
            $selectBox->setAttribs( array('class'=> 'last-child' ) );
            $selectBox->setDecorators( $this->_decoratorDefault );
            $selectBox->addMultiOptions( array() );
            $selectBox->addFilters( array('StringTrim','StripTags') );
        $this->addElement( $selectBox );		

        $txtDtInicial = new Zend_Form_Element_Text( 'dt_nascimento' );
			$txtDtInicial->setLabel( 'Data Nascimento:' );
			$txtDtInicial->setAttribs( array( 'size'=>'15' ,'class'=>'campo_data' ) );
			$txtDtInicial->setDecorators( $this->_decoratorLeft );
        $this->addElement( $txtDtInicial );		

        $obSexoRepositorio = new App_Model_ParamSexoRepository();
        $selectBoxSexo = new Zend_Form_Element_Select( 'co_sexo' );
            $selectBoxSexo->setLabel('Sexo:');
            $selectBoxSexo->setAttribs( array('class'=> 'last-child' ) );
            $selectBoxSexo->setDecorators( $this->_decoratorLeft );
            $selectBoxSexo->addMultiOptions( Voitech_Util::converteModeloArrayCombo($obSexoRepositorio->listarTodos(array('st_ativo'=>'S'))
                                            , 'CoSexo', 'NoSexo', true) );
            $selectBoxSexo->addFilters( array('StringTrim','StripTags') );
        $this->addElement( $selectBoxSexo );

        $obCivilRepositorio = new App_Model_ParamEstadoCivilRepository();
        $selectBoxCivil = new Zend_Form_Element_Select( 'co_estado_civil' );
            $selectBoxCivil->setLabel('Estado Civil:');
            $selectBoxCivil->setAttribs( array('class'=> 'last-child' ) );
            $selectBoxCivil->setDecorators( $this->_decoratorDefault );
            $selectBoxCivil->addMultiOptions( Voitech_Util::converteModeloArrayCombo($obCivilRepositorio->listarTodos(array('st_ativo'=>'S'))
                                            , 'CoEstadoCivil', 'NoEstadoCivil', true)  );
            $selectBoxCivil->addFilters( array('StringTrim','StripTags') );
        $this->addElement( $selectBoxCivil );	
		
		$this->addDisplayGroup(array('co_pessoa','no_pessoa','nu_cpf','nu_rg','no_rg_emissor','sg_uf_rg_emissor','no_endereco','no_complemento','no_bairro','sg_uf','co_cidade','dt_nascimento','co_sexo','co_estado_civil'),'Cadastro',array('legend' => 'Dados Pessoais', 'class'=>'grey-bg first-child last-child fieldset-with-legend fieldset-with-legend-first-child'));
	}
}